import { ApiCall } from "tsrpc";
import { ReqCallAllMsg, ResCallAllMsg } from "../../../../shared/master/bag/function/PtlCallAllMsg";
import { player } from "../../../../model/fight/body/player";
import { template } from "../../../../shared/master/MsgAction";
import manage_user from "../../../model/manage/manage_user";

export default async function (call: ApiCall<ReqCallAllMsg, ResCallAllMsg>) {
    call.succ({})
    let user = call.req._player as player;
    let msg = call.req.msg;
    if(msg.length > 240){
        user.sendMsg(template.default,'你要发送的消息过长啦~')
        return;
    }
    let res = user.check_wallet(0, 0, [{ id: 'prop-18', v: 1 }], false, `发送全服消息`, true);
    if (!res.state) {
        return;
    }

    user.sendMsg(template.default,`已向全服${manage_user.getOnlineCont()}个玩家发送消息`)
    manage_user.sendAllMsg(template.default_none,`📢${user.nickName}:${msg}`)

}